package org.loofer.uikit;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import org.loofer.ext.utils.ObjectUtils;
import java.util.ArrayList;
import java.util.List;

public class ExtendTabHost extends TabHost {
    private List<TabSpec> mTabSpecs = new ArrayList();

    public ExtendTabHost(Context context) {
        super(context);
    }

    public ExtendTabHost(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void addTab(TabSpec tabSpec) {
        super.addTab(tabSpec);
        if (tabSpec != null) {
            this.mTabSpecs.add(tabSpec);
        }
    }

    public void clearAllTabs() {
        super.clearAllTabs();
        this.mTabSpecs.clear();
    }

    public int getTabCount() {
        return this.mTabSpecs.size();
    }

    public TabSpec getTabAt(int index) {
        if (index < 0 || index >= this.mTabSpecs.size()) {
            return null;
        }
        return (TabSpec) this.mTabSpecs.get(index);
    }

    public List<TabSpec> getAllTabs() {
        return new ArrayList(this.mTabSpecs);
    }

    public TabSpec getTabByTag(String tag) {
        for (TabSpec spec : this.mTabSpecs) {
            if (ObjectUtils.equals(tag, spec.getTag())) {
                return spec;
            }
        }
        return null;
    }
}
